package leecode;

/**
 * 功能描述：剪绳子问题
 *
 * @Author: lwg
 * @Date: 2021/4/10 22:17
 */
public class demo14 {
    public static int cutRoge(int n) {
        int[] dp = new int[n + 1];
        dp[2] = dp[1] = 1;
        for (int i = 3; i < n + 1; i++) {
            for (int j = 2; j < i; j++) {
                dp[i] = Math.max(dp[i], Math.max(j * (i - j), j * dp[i - j]));
            }
        }
        return dp[n];
    }

    public static void main(String[] args) {
        System.out.println(cutRoge(10));
    }
}
